package com.googlecode.openauth.web.entity;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.apache.commons.lang.StringUtils;

public class UserInfo {
	/**
	 * 
	 */
	private static final long serialVersionUID = 26069948914026191L;
	// 用户id,唯一值
	private long userId;
	// 用户 uuid ,唯一值
	private String uuid;
	// 用户名称
	private String username;
	// 用户密码
	private String password;
	// 组织机构代码
	private String corporateCode;
	private String address;
	private String phone;
	private String fax;
	private String email;
	private String description;
	// 省份证号
	private String idCard;
	private String registerIp;
	private Timestamp registerDate = new Timestamp(System.currentTimeMillis());
	// 警号
	private String userPoliceNo;
	
	private List<RoleInfo> roleInfos = new ArrayList<RoleInfo>();
	private int roleId;
	
	public UserInfo() {
		uuid = UUID.randomUUID().toString();
	}

	public int getRoleId() {
	return roleId;
	}
	
	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getCorporateCode() {
		return corporateCode;
	}

	public void setCorporateCode(String corporateCode) {
		this.corporateCode = corporateCode;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public String getRegisterIp() {
		return registerIp;
	}

	public void setRegisterIp(String registerIp) {
		this.registerIp = registerIp;
	}

	public Timestamp getRegisterDate() {
		return registerDate;
	}

	public void setRegisterDate(Timestamp registerDate) {
		this.registerDate = registerDate;
	}

	public String getUserPoliceNo() {
		return userPoliceNo;
	}

	public void setUserPoliceNo(String userPoliceNo) {
		this.userPoliceNo = userPoliceNo;
	}

	public List<RoleInfo> getRoleInfos() {
		return roleInfos;
	}

	public void setRoleInfos(List<RoleInfo> roleInfos) {
		this.roleInfos = roleInfos;
	}

	public String toString(){
		StringBuilder builder = new StringBuilder();
		
		builder.append(" user id : ");
		builder.append(userId);
		
		if(!StringUtils.isEmpty(username)){
			builder.append(" user name : ");
			builder.append(username);
		}
		
		if(!StringUtils.isEmpty(uuid)){
			builder.append(" uuid  : ");
			builder.append(uuid);
		}
		
		if(!StringUtils.isEmpty(corporateCode)){
			builder.append(" corporate code  : ");
			builder.append(corporateCode);
		}
		
		if(!StringUtils.isEmpty(address)){
			builder.append(" address  : ");
			builder.append(address);
		}
		
		if(!StringUtils.isEmpty(phone)){
			builder.append(" phone  : ");
			builder.append(phone);
		}
		
		if(!StringUtils.isEmpty(fax)){
			builder.append(" fax  : ");
			builder.append(fax);
		}
		
		if(!StringUtils.isEmpty(registerIp)){
			builder.append(" registerIp  : ");
			builder.append(registerIp);
		}
		
		if(!StringUtils.isEmpty(userPoliceNo)){
			builder.append(" userPoliceNo  : ");
			builder.append(userPoliceNo);
		}
		
		if(getRoleInfos() != null && !getRoleInfos().isEmpty()){
			builder.append(" userRoles : ");
			builder.append( getRoleInfos() );
		}
				
		return builder.toString();
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
}
